function getCookie (name) {
  if (document.cookie.length > 0) {
    var cstart = document.cookie.indexOf(name + '=')
    if (cstart !== -1) {
      cstart = cstart + name.length + 1
      var cend = document.cookie.indexOf(';', cstart)
      if (cend === -1) {
        cend = document.cookie.length
      }
      return unescape(document.cookie.substring(cstart, cend))
    }
  }
  return ''
}

function setCookie (name, value, expiredays) {
  var exdate = new Date()
  exdate.setDate(exdate.getDate() + expiredays)
  document.cookie = name + '=' + escape(value) +
    ((expiredays == null) ? '' : ';expires=' + exdate.toGMTString())
}
const cookie = {
  get: getCookie,
  set: setCookie
}
export default cookie
